﻿
@{
	ViewBag.Title = "GetMaintainRecord";

}

<link rel="stylesheet" href="../../Customiz/layui/css/layui.css" media="all">
<link rel="stylesheet" href="../../Customiz/css/admin.css" media="all">

<div class="layui-fluid">
	<div class="layui-form layui-card-header layuiadmin-card-header-auto">
		<div class="layui-form-item">
			<div class="layui-inline">
				<label class="layui-form-label">军械名称</label>
				<div class="layui-input-block">
					<input type="text" name="Maintain_Name" placeholder="请输入" autocomplete="off" class="layui-input">
				</div>
			</div>
			<div class="layui-inline">
				<label class="layui-form-label">所属仓库</label>
				<div class="layui-input-block">
					<select name="Warehouse" id="Warehouse">
						<option value=""></option>
					</select>
				</div>
			</div>
			<div class="layui-inline">
				<button class="layui-btn layuiadmin-btn-admin" lay-submit lay-filter="Ord-Record-back-search">
					<i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
				</button>
			</div>
		</div>
	</div>
	<div class="layui-card">
		<div class="layui-card-body">

			<table id="Ord_MaintainRecord_Table" lay-filter="Ord_MaintainRecord_Table"></table>

		</div>
	</div>
</div>

<script src="../../Customiz/layui/layui.js"></script>
<script>

    layui.use(['table'], function () {
		var table = layui.table;
		var form = layui.form;
		var $ = layui.$;
		var layer = layui.layer;

		$.ajax({
            url: '/Index/GetWarehouseData',
            dataType: 'json',
            type: 'Post',
            success: function (data) {
                $.each(data.data, function (index, item) {
                    $('#Warehouse').append(new Option(item.Warehouse_Name, item.Warehouse_ID)); // 下拉菜单里添加元素
                });
                layui.form.render("select");
                //重新渲染 固定写法
            }
        })
        //用户管理
        table.render({
            elem: '#Ord_MaintainRecord_Table',
			url: '/Maintain/GetRecord', //模拟接口
            page: true,
            cols: [
                [{
                    type: 'checkbox',
                    fixed: 'left'
                }, {
                    field: 'Maintain_Name',
                    title: '军械名称'
				}, {
					field: 'Maintain_Batch',
					title: '军械批次'
				}, {
					field: 'Maintain_WarehouseName',
					title: '仓库名称'
				},  {
                    field: 'Maintain_Num',
                    title: '军械数量'
				}, {
                    field: 'Maintain_Time',
                    title: '维修时间'
				}
                ]
            ],
            text: '对不起，加载出现异常！'
        });

        //监听查询
		//监听搜索
		form.on('submit(Ord-Record-back-search)', function (data) {
			var field = data.field;

			//执行重载
			table.reload('Ord_MaintainRecord_Table', {
				where: field
			});
		});

        //监测点击，根据值确认执行哪个操作
        $('.layui-btn.layuiadmin-btn-admin').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });

    });
</script>

